package top.vains.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.vains.entity.Permission;
import top.vains.entity.customer.PermissionCustomer;
import top.vains.mapper.PermissionMapper;
import top.vains.service.IPermissionService;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author vains
 * @since 2020-02-17
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {

    @Override
    public List<Permission> selectPermissionsById(Integer userId) {
        return baseMapper.selectPermissionsById(userId);
    }

    @Override
    public List<Permission> selectPermissions() {
        QueryWrapper<Permission> wrapper = new QueryWrapper<>();
        wrapper.eq("type", 1);
        wrapper.eq("deleted", false);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<Permission> selectMenus() {
        QueryWrapper<Permission> wrapper = new QueryWrapper<>();
        wrapper.eq("type", 0);
        wrapper.eq("deleted", false);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<PermissionCustomer> selectPermissionsDetails(String name) {
        return baseMapper.selectPermissionsDetails(name);
    }
}
